/**
 * 
 */
package club325.webchat.servlet.statistics;

import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;

import club325.webchat.database.command.StatisticsDBInterface;
import club325.webchat.database.command.UserDBInterface;
import club325.webchat.model.StatisticsBean;

/**
 * @author Sider
 *
 */
public class StatisticManager
{
	public static void UserLogin(String UserID) throws ServletException
	{
		UserDBInterface.UserLogin(UserID);
		StatisticsDBInterface.UserLogin(UserID);
	}
	
	public static void UserLogout(String UserID)
	{
		StatisticsDBInterface.UserLogout(UserID);
	}
	
	public static void VisitorLogin(String IP)
	{
		StatisticsDBInterface.VisitorLogin(IP);
	}
	
	public static void VisitorLogout(String IP)
	{
		StatisticsDBInterface.VisitorLogout(IP);
	}
	
	public static int GetTodayUserCount()
	{
		return StatisticsDBInterface.GetTodayUserCount();
	}
	
	public static int GetTodayVisitorCount()
	{
		return StatisticsDBInterface.GetTodayVisitorCount();
	}
	
	public static int GetThisMonthUserCount()
	{
		return StatisticsDBInterface.GetThisMonthUserCount();
	}
	
	public static int GetThisMonthVisitorCount()
	{
		return StatisticsDBInterface.GetThisMonthVisitorCount();
	}
	
	public static int GetThisYearUserCount()
	{
		return StatisticsDBInterface.GetThisYearUserCount();
	}
	
	public static int GetThisYearVisitorCount()
	{
		return StatisticsDBInterface.GetThisYearVisitorCount();
	}
	
	public static List<Integer> GetLast7DayUserCount()
	{
		return StatisticsDBInterface.GetLast7DayUserCount();
	}
	
	public static List<Integer> Getlast7DayVisitorCount()
	{
		return StatisticsDBInterface.GetLast7DayVisitorCount();
	}
	
	public static int GetTimeUserCount(Date Start,Date End)
	{
		return StatisticsDBInterface.GetTimeUserCount(Start, End);
	}
	
	public static int GetTimeVisitorCount(Date Start,Date End)
	{
		return StatisticsDBInterface.GetTimeVisitorCount(Start, End);
	}
	
	public static StatisticsBean getStatisticsInfo()
	{
		StatisticsBean bean = new StatisticsBean();
		bean.setLastSevenDaysUser(GetLast7DayUserCount());
		bean.setLastSevenDaysVisitor(Getlast7DayVisitorCount());
		bean.setThisMonthUser(GetThisMonthUserCount());
		bean.setThisMonthVisitor(GetThisMonthVisitorCount());
		bean.setThisYearUser(GetThisYearUserCount());
		bean.setThisYearVisitor(GetThisYearVisitorCount());
		bean.setTodayUser(GetTodayUserCount());
		bean.setTodayVisitor(GetTodayVisitorCount());
		return bean;
	}
}